import { observable, action, autorun, toJS } from 'mobx';
import { WeaTableNew, WeaForm } from 'comsMobx';
import { message } from 'antd';
import * as Apis from './../apis/contact';

export default class ContactRemarkItemStore {
    @observable inputValue = '';
    combj = {};
    @observable remarks = [];
    @observable show = false;

    @action
    doInit = (combj) => {
      this.combj = combj;
      this.remarks = combj.props.data;
    }
    @action
    saveRemarkCmd = (params) => {
      if (this.inputValue == '') {
        this.combj.refs.weaError.showError();
        return;
      }
      Apis.saveRemarkCmd({ ...params, text: this.inputValue }).then((result) => {
        if (result.status == 'success') {
          this.show = false;
          this.combj.props.getContactLogsRemark();
          this.inputValue = '';
        } else {
          message.error(result.msgcode);
        }
      });
    }

    @action
    setInputValue = (value) => {
      this.inputValue = value;
    }

    @action
    setShow = (show) => {
      this.show = show;
    }
}
